



**************************************************************************************************************************************************************
**************************************************************************************************************************************************************

****** Open data, harmonize variable names, merge data sets

**************************************************************************************************************************************************************
**************************************************************************************************************************************************************



* /////////////////////////////////
* // PREPARING DATA SET PTU 2013 //
* /////////////////////////////////


use "PTU 2013.dta"


* Parliamentary assemblies
rename F1_KOMMUN KommunF
rename F1_LANDSTING LandstingF
rename F1_RIKSDAG Riksdag

* year variable
gen year=2013

* gender variable
gen female=.
replace female=1 if KOeN==2
replace female=0 if KOeN==1
label define female 1 "women" 0 "men"
label values female female
drop KOeN


* party variable
gen party=.
replace party =1 if partitillhoerighet==5
replace party =2 if partitillhoerighet==2 
replace party =3 if partitillhoerighet==6
replace party =4 if partitillhoerighet==4 
replace party =5 if partitillhoerighet==7
replace party =6 if partitillhoerighet==3 
replace party =7 if partitillhoerighet==1
replace party =8 if partitillhoerighet==8
replace party =9 if party==.

label define party 1 "v" 2 "s" 3 "mp" 4 "c" 5 "kd" 6 "l" 7 "m" 8 "sd" 9 "other" 
label values party party

drop partitillhoerighet
drop Parti

* rename variables and drop irrelevant variables to harmonize to other waves
rename F73_01 G73_01
rename F73_02 G73_02
rename F73_03 G73_03
rename F73_04 G73_04
rename F73_05 G73_05

drop Vikt NUTS2 NUTS1 Kommun f22psum

rename Tilltradesdatum Tilltraedesdatum
rename Lan Laen
rename Valomradesnamn Valomraadesnamn
rename F1_antalpolfoersaml antalpolfoersaml
rename POLISMYNDIG POLISREGION
rename F4_Fullmaektige Fullmaektige
rename F4_Styrelse Styrelse
rename F4_Haelso_sjuk Haelso_sjuk
rename F4_Kultur_fritid Kultur_fritid
rename F4_Plan_bygg Plan_bygg
rename F4_Social Social
rename F4_Teknisk Teknisk
rename F4_Utbildning Utbildning
rename F4_Annan1 Annan1
rename F4_Annan2 Annan2
rename F4_Annan3 Annan3
rename F4_ANTALUPPDRAG ANTALUPPDRAG
rename F4_Ordfoerande Ordfoerande
rename F4_Foerstevordf Foerstevordf
rename F4_Ord_ledamot Ord_ledamot
rename F4_Ersaettare Ersaettare
rename F8_bakgrund BAKGRUND
rename antalpolfoersaml antalpolfoersaml2



* /////////////////////////////////
* // MERGING WITH OTHER YEARS    //
* /////////////////////////////////

append using "PTU15.dta"
append using "PTU17.dta"



**************************************************************************************************************************************************************
**************************************************************************************************************************************************************

****** Coding variables

**************************************************************************************************************************************************************
**************************************************************************************************************************************************************



* Only keep municipal politicians
gen municipality=1 if KommunF==1
replace municipality=0 if KommunF==.
keep if municipality==1


***************************************************************************************
***************************************************************************************
******************************* VIOLENCE ***************************************
***************************************************************************************
***************************************************************************************

*	1. VIOLENCE PREVIOUS YEAR, EACH FORM

rename F13_01 pyear_severe_phy_violence
rename F13_02 pyear_moderate_phy_violence
rename F13_03 pyear_weapon_violence
rename F13_04 pyear_arson
rename F13_05 pyear_graffiti
rename F13_06 pyear_theft
rename F13_07 pyear_other_damage
rename F13_08 pyear_other_phy_violence

rename F38_01 pyear_threat_verbal
rename F38_02 pyear_threat_phone
rename F38_03 pyear_threat_text
rename F38_04 pyear_threat_mail
rename F38_05 pyear_threat_email
rename F38_06 py_attack_social_media
rename F38_07 pyear_hijacked_account
rename F38_08 pyear_online_libel
rename F38_09 pyear_poster_pamphlet_libel
rename F38_10 pyear_undesired_order
rename F38_11 pyear_threat_gift
rename F38_12 pyear_unsolicited_photo_record
rename F38_13 pyear_stalking
rename F38_14 pyear_falsely_denounced
rename F38_15 pyear_threat_other

replace	pyear_severe_phy_violence =0 if	pyear_severe_phy_violence ==.
replace	pyear_moderate_phy_violence =0 if	pyear_moderate_phy_violence ==.
replace	pyear_weapon_violence =0 if	pyear_weapon_violence==.
replace	pyear_arson =0 if	pyear_arson==.
replace	pyear_graffiti =0 if	pyear_graffiti==.
replace	pyear_theft =0 if	pyear_theft==.
replace	pyear_other_damage =0 if	pyear_other_damage==.
replace	pyear_other_phy_violence =0 if	pyear_other_phy_violence==.
			
replace	pyear_threat_verbal	=0 if	pyear_threat_verbal==.
replace	pyear_threat_phone	=0 if	pyear_threat_phone==.
replace	pyear_threat_text	=0 if	pyear_threat_text==.
replace	pyear_threat_mail=0	if	pyear_threat_mail==.
replace	pyear_threat_email=0	if	pyear_threat_email==.
replace	py_attack_social_media=0	if	py_attack_social_media==.
replace	pyear_hijacked_account=0	if	pyear_hijacked_account==.
replace	pyear_online_libel=0	if	pyear_online_libel==.
replace	pyear_poster_pamphlet_libel=0	if	pyear_poster_pamphlet_libel==.
replace	pyear_undesired_order=0	if	pyear_undesired_order==.
replace	pyear_threat_gift=0	if	pyear_threat_gift==.
replace	pyear_unsolicited_photo_record=0	if	pyear_unsolicited_photo_record==.
replace	pyear_stalking=0	if	pyear_stalking==.
replace	pyear_falsely_denounced=0	if	pyear_falsely_denounced==.
replace	pyear_threat_other=0	if	pyear_threat_other==.

*	2. Any violence previous year, includes all violence types 
gen violence_pyear=.
replace violence_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 ///
 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  ///
 |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | ///
 pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1| ///
 pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | ///
 pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| ///
 pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence_pyear=0 if violence_pyear==.

*	3. SUBTYPES VIOLENCE PREVIOUS YEAR

*	Five forms of violence

gen py_bodily=.
replace py_bodily=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 | pyear_weapon_violence==1| pyear_other_phy_violence==1
replace py_bodily=0 if py_bodily==.
gen py_damage=.
replace py_damage=1 if pyear_arson==1| pyear_graffiti==1| pyear_other_damage==1 | pyear_theft==1 | pyear_undesired_order==1
replace py_damage=0 if py_damage==.
gen py_threat=.
replace py_threat=1 if pyear_threat_verbal==1 | pyear_threat_phone==1 | pyear_threat_text==1| ///
 pyear_threat_mail==1|pyear_threat_email==1|pyear_threat_gift==1|pyear_threat_other==1
replace py_threat=0 if py_threat==.
gen py_character_assassination=.
replace py_character_assassination=1 if pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1
replace py_character_assassination=0 if py_character_assassination==.
gen py_harassment=.
replace py_harassment=1 if pyear_unsolicited_photo_record==1| pyear_stalking==1|pyear_falsely_denounced==1 | py_attack==1
replace py_harassment=0 if py_harassment==.


*	Number of violence forms experienced previous year
gen forms_violence=pyear_severe_phy_violence + pyear_moderate_phy_violence + pyear_weapon_violence ///
+ pyear_arson + pyear_graffiti+ pyear_theft + pyear_other_damage + pyear_other_phy_violence+ ///
 pyear_threat_verbal+ pyear_threat_phone+ pyear_threat_text+ pyear_threat_mail+ pyear_threat_email ///
 + py_attack_social_media+ pyear_hijacked_account+ pyear_online_libel+ pyear_poster_pamphlet_libel+ ///
 pyear_undesired_order+ pyear_threat_gift+ pyear_unsolicited_photo_record+ pyear_stalking+ ///
 pyear_falsely_denounced+ pyear_threat_other
 
 

***************************************************************************************

*	Leaving politics

***************************************************************************************

gen considered_leaving_politics=0 if F78_c==2
replace considered_leaving_politics=1 if F78_c==1


***************************************************************************************
***************************************************************************************
*************************** RESPONDENT CHARACTERISTICS *************************
***************************************************************************************
***************************************************************************************


*	Background characteristics


* Gender
gen woman=1 if female==1
replace woman=0 if female==0


* Foreign background
gen foreign_born= 1 if F8==4
replace foreign_born=1 if N1==2
replace foreign_born=0 if F8==1 | F8==2 | F8==3
replace foreign_born=0 if N1==1

gen parents_foreign_born=1 if F8==3
replace parents_foreign =1 if F8==2
replace parents_foreign=0 if F8==1
replace parents_foreign=1 if N2==2
replace parents_foreign=1 if N2==3
replace parents_foreign=0 if N2==1

replace parents_foreign_born=0 if foreign_born==1

gen foreign_born2=foreign_born
replace foreign_born2 =1 if parents_foreign_born ==1 &foreign_born==1



gen foreign_background=0 if foreign_born==0
replace foreign_background=0 if parents_f==0
replace foreign_background=1 if foreign_born==1 
replace foreign_background=1 if parents_foreign_born==1

gen type_foreign_background=1 if parents==1
replace type_foreign_background=0 if foreign_born==1
label define type_foreign_back 1 "parents foreign born" 0 "foreign born"
label values type_foreign_back type_foreign_back


* Age: Young
gen young=1 if aalder<35
replace young=1 if aalder==35
replace young=0 if aalder>35



* Experience: newcomer
* definition: everything up to "not more than 5 years" for the waves in between election years
* 1 year or less for election year wave
gen newcomer =1 if F2 ==1 
replace newcomer=1 if F2==2 & year==2013
replace newcomer =1 if F2==2 & year==2017
replace newcomer=1 if F2==3 & year==2013
replace newcomer =1 if F2==3 & year==2017
replace newcomer=0 if newcomer==.


*	Hierarchical prominence

*	Hierarchy in 3 levels
gen level_of_power=.
*rank and file
replace level_of_power=1 if level_of_power==. & KommunF==1
*committee chair
replace level_of_power=2 if F4_01==1 & KommunF==1| F4_03==1 & KommunF==1| F4_04==1 & KommunF==1| F4_05==1 & KommunF==1| F4_06==1 & KommunF==1 | F4_07==1 & KommunF==1| F4_08==1 & KommunF==1| F4_09==1 & KommunF==1| F4_10==1 & KommunF==1| F4_11==1 & KommunF==1
*mayor
replace level_of_power=3 if F4_02==1 & KommunF==1

label define level_of_power 1 "rankfile" 2 "committee or assembly chair" 3 "mayor"
label values level_of_power level_of_power

*	mutually exclusive dummies for each level of power
gen l_rankfile=1 if level==1
replace l_rankfile=0 if l_rankfile==.
gen l_chair=1 if level==2
replace l_chair=0 if l_chair==.
gen l_mayor=1 if level==3
replace l_mayor=0 if l_mayor==.




***************************************************************************************
***************************************************************************************

*							Other variables

***************************************************************************************
***************************************************************************************




**************** ADD MUNICIPALITY VARIABLES *********************


capture drop _merge

joinby kommunkod using "skr_kommungrupp2023.dta", unmatched(master)

gen mun_type=1 if huvudgrupp=="Storstäder och storstadsnära kommuner"
replace mun_type=2 if huvudgrupp=="Större städer och kommuner nära större stad"
replace mun_type=3 if huvudgrupp=="Mindre städer/tätorter och landsbygdskommuner"

label define mun_type 1 "Large cities" 2 "Medium sized cities" 3 "Smaller cities and rural municipalitites"
label values mun_type mun_type

capture drop _merge

joinby kommunkod using "foreignborn_municipality_scb.dta", unmatched(master)

gen quartiles_foreignborn=.
replace quartiles=1 if share_foreignborn<11.5
replace quartiles=2 if share_foreignborn>11.5 & share_foreignborn<14.4
replace quartiles=3 if share_foreignborn>14.4 & share_foreignborn<18.8
replace quartiles=4 if share_foreignborn>18.8

gen sq_foreignborn=share_foreignborn^2



**************************************************************************************************************************************************************
**************************************************************************************************************************************************************
*******************************


* ANALYSES


*******************************
**************************************************************************************************************************************************************
**************************************************************************************************************************************************************


*********************************************
*********************************************
* Main analyses
*********************************************
*********************************************


* Figure 1: Violence against politicians with and without a foreign background
* This corresponds to Table A2 in the paper, and numbers from this table are used to generate Figure 1.
xi:areg violence foreign_back i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_foreignback1, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg py_bodily foreign_back i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_foreignback1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_damage foreign_back i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_foreignback1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_threat foreign_back i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_foreignback1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_character_assassination foreign_back i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_foreignback1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg  py_harassment foreign_back i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_foreignback1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg forms_violence foreign_back i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_foreignback1, ctitle ("") dec(3) se excel slow(1500) append


*********************************************
* ALTERNATIVE ESTIMATORS
*********************************************

* Table A3: Logit
xi:logit violence foreign_back young newcomer woman i.party i.year i.level i.kommunkod, cl(kommunkod)
outreg2 using logit1, ctitle ("") dec(3) se excel slow(1500) replace
xi:logit considered_leaving_all foreign_background young newcomer woman i.party i.year i.level i.kommunkod, cl(kommunkod)
outreg2 using logit1, ctitle ("") dec(3) se excel slow(1500) append

* Table A4
** COUNT MODEL: Number of forms of violence
* Zero inflated negative binomial
xi:zinb forms_violence foreign_back ///
i.party i.year i.level woman young newcomer, inflate(foreign_back ///
i.party i.year i.level woman young newcomer) cl(kommunkod) irr


*********************************************
*********************************************
* SEPARATE ANALYSES FOR WOMEN AND MEN
*********************************************
*********************************************

* Figure 2: Violence against women and men with and without an immigrant background
* This corresponds to Table A5 in the paper, and numbers from this table are used to generate Figure 2.
xi:areg violence foreign_back i.party i.year i.level young newcomer if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg py_bodily foreign_back i.party i.year i.level young newcomer if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_damage foreign_back i.party i.year i.level young newcomer if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_threat foreign_back i.party i.year i.level young newcomer if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_character_assassination foreign_back i.party i.year i.level young newcomer if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg  py_harassment foreign_back i.party i.year i.level young newcomer if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg violence foreign_back i.party i.year i.level young newcomer if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_bodily foreign_back i.party i.year i.level young newcomer if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_damage foreign_back i.party i.year i.level young newcomer if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_threat foreign_back i.party i.year i.level young newcomer if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_character_assassination foreign_back i.party i.year i.level young newcomer if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append
xi:areg  py_harassment foreign_back i.party i.year i.level young newcomer if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using violence_womenmen, ctitle ("") dec(3) se excel slow(1500) append

*********************************************
*********************************************
* GENDER*IMMIGRANT BACKGROUND INTERACTION
*********************************************
*********************************************

* Table A6
xi:areg violence c.woman##c.foreign_back i.party*i.woman i.year*i.woman i.young*i.woman i.newcomer*i.woman i.level*i.woman, abs(kommunkod) cl(kommunkod)
outreg2 using violence_gender, ctitle ("") dec(3) se excel slow(1500) replace


**********************************************************
*********************************************
* SEPARATING FOREIGN BORN AND HAVING FOREIGN BORN PARENTS
*********************************************
**********************************************************

* Figure 3: Type of migration background and violence
* This corresponds to Table A7 in the paper, and numbers from this table are used to generate Figure 3.
xi:areg violence parents_foreign_born foreign_born i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_pforeignbornforeignborn2, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg py_bodily parents_foreign_born foreign_born i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_pforeignbornforeignborn2, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_damage parents_foreign_born foreign_born i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_pforeignbornforeignborn2, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_threat parents_foreign_born foreign_born i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_pforeignbornforeignborn2, ctitle ("") dec(3) se excel slow(1500) append
xi:areg py_character_assassination parents_foreign_born foreign_born i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_pforeignbornforeignborn2, ctitle ("") dec(3) se excel slow(1500) append
xi:areg  py_harassment parents_foreign_born foreign_born i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
outreg2 using violence_pforeignbornforeignborn2, ctitle ("") dec(3) se excel slow(1500) append



*********************************************
*********************************************
* DIFFERENT TYPES OF MUNICIPALITIES
*********************************************
*********************************************

* Table A8
* Type of municipality
xi:areg violence foreign_back i.party i.year i.level female young newcomer if mun_type==1, abs(kommunkod) cl(kommunkod)
outreg2 using muntype1, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg violence foreign_back i.party i.year i.level female young newcomer if mun_type==2, abs(kommunkod) cl(kommunkod)
outreg2 using muntype1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg violence foreign_back i.party i.year i.level female young newcomer if mun_type==3, abs(kommunkod) cl(kommunkod)
outreg2 using muntype1, ctitle ("") dec(3) se excel slow(1500) append

* Table A9
* Share of foreign born in municipality
xi:areg violence foreign_back i.party i.year i.level female young newcomer if quartiles==1, abs(kommunkod) cl(kommunkod)
outreg2 using share_f1, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg violence foreign_back i.party i.year i.level female young newcomer if quartiles==2, abs(kommunkod) cl(kommunkod)
outreg2 using share_f1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg violence foreign_back i.party i.year i.level female young newcomer if quartiles==3, abs(kommunkod) cl(kommunkod)
outreg2 using share_f1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg violence foreign_back i.party i.year i.level female young newcomer if quartiles==4, abs(kommunkod) cl(kommunkod)
outreg2 using share_f1, ctitle ("") dec(3) se excel slow(1500) append
xi:reg violence foreign_back i.party i.year i.level female young newcomer share_foreignborn sq_foreignborn, cl(kommunkod)
outreg2 using share_f1, ctitle ("") dec(3) se excel slow(1500) append

* Figure A3
xi:areg violence i.party i.year i.level female young newcomer, abs(kommunkod) cl(kommunkod)
predict violenceresidual, resid
gen imviolenceresidual = violenceresidual if foreign_back==1
gen nonimviolenceresidual= violenceresidual if foreign_back==0

collapse (mean)imviolenceresidual nonimviolenceresidual share_foreignborn, by(kommunkod year)
gen diff =imviolenceresidual-nonimviolenceresidual
binscatterhist diff share_foreignborn, linetype(connect)


*********************************************
*********************************************
* CONSIDERING LEAVING POLITICS
*********************************************
*********************************************

* Table 2
xi:areg considered_leaving_politics foreign_background young newcomer woman i.party i.year i.level, abs(kommunkod) cl(kommunkod)
outreg2 using leaving1, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg considered_leaving_politics foreign_background young newcomer i.party i.year i.level if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving_politics foreign_background young newcomer i.party i.year i.level if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using leaving1, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving_politics woman i.party i.year i.level young newcomer if foreign_back==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving1, ctitle ("") dec(3) se excel slow(1500) append


* Table A10
* Differentiating across type of migration background, and across gender
xi:areg considered_leaving parents_foreign foreign_born i.party i.year i.level young newcomer woman, abs(kommunkod) cl(kommunkod)
outreg2 using leaving3, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg considered_leaving parents_foreign foreign_born i.party i.year i.level young newcomer if woman==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving3, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving parents_foreign foreign_born i.party i.year i.level young newcomer if woman==0, abs(kommunkod) cl(kommunkod)
outreg2 using leaving3, ctitle ("") dec(3) se excel slow(1500) append


* Table A11
* subsample of violence exposed politicians
xi:areg considered_leaving_politics foreign_background young newcomer woman i.party i.year i.level if violence==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving2, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg considered_leaving_politics foreign_background young newcomer i.party i.year i.level if woman==1 & violence==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving2, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving_politics foreign_background young newcomer i.party i.year i.level if woman==0 & violence==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving2, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving_politics woman young newcomer i.party i.year i.level if foreign_background==1 & violence==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving2, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving_politics parents_foreign foreign_born young newcomer woman i.party i.year i.level if violence==1, abs(kommunkod) cl(kommunkod)
outreg2 using leaving2, ctitle ("") dec(3) se excel slow(1500) append

* Table A12
* subsample of non-violence exposed politicians
xi:areg considered_leaving_politics foreign_background young newcomer woman i.party i.year i.level if violence==0, abs(kommunkod) cl(kommunkod)
outreg2 using leaving3, ctitle ("") dec(3) se excel slow(1500) replace
xi:areg considered_leaving_politics foreign_background young newcomer i.party i.year i.level if woman==1 & violence==0, abs(kommunkod) cl(kommunkod)
outreg2 using leaving3, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving_politics foreign_background young newcomer i.party i.year i.level if woman==0 & violence==0, abs(kommunkod) cl(kommunkod)
outreg2 using leaving3, ctitle ("") dec(3) se excel slow(1500) append
xi:areg considered_leaving_politics woman young newcomer i.party i.year i.level if foreign_back==1 & violence==0, abs(kommunkod) cl(kommunkod)
outreg2 using leaving3, ctitle ("") dec(3) se excel slow(1500) append

